package sports;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Sports_recordList;
import algorithm.Personal_sportscredit_ranking;

public class Personal_ranking extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Personal_sportscredit_ranking personal_sportscredit_ranking = new Personal_sportscredit_ranking();
		String useraccount = request.getSession().getAttribute("user_account").toString();
		Map<String,Object> map = personal_sportscredit_ranking.Get_Ranking(Sports_recordList.getSports_records(), useraccount);
		request.setAttribute("basketball_ranking", map.get("basketball"));
		request.setAttribute("swimming_ranking", map.get("swimming"));
		request.setAttribute("running_ranking", map.get("running"));
		request.getRequestDispatcher("/rangking.jsp").forward(request, response);
	}

}
